package cn.itcast.hotel.listen;

import cn.itcast.hotel.constants.MqConstants;
import cn.itcast.hotel.service.IHotelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @作者 itcast
 * @创建日期 2021/11/6 15:10
 **/
@Component
@Slf4j
public class HotelListener {
    @Autowired
    IHotelService hotelService;


    @RabbitListener(queues = MqConstants.HOTEL_INSERT_QUEUE)
    public void listenInsertMsg(Long hotelId){
        log.info("接收到 更新酒店消息通知  酒店id:{}",hotelId);
        hotelService.insert(hotelId);
    }
    @RabbitListener(queues = MqConstants.HOTEL_DELETE_QUEUE)
    public void listenDeleteMsg(Long hotelId){
        log.info("接收到 删除酒店消息通知  酒店id:{}",hotelId);
        hotelService.delete(hotelId);
    }
}
